# system("python SolveHarmonicOscillator1D.py")

file.dir <- "./data/"
i <- 0
print(dir(file.dir))
for(infile in dir(file.dir)) {

    data <- read.csv(file=paste(file.dir,infile,sep=""),head=FALSE,sep=",")
    # now can access each as data$V1 or data$V3

    outfilename = paste("./plots/time_", sprintf("%03d",i), ".pdf", sep="")
    i <- i+1
    
    pdf(outfilename) # makes a pdf printing device for plots
    plot(data$V1,data$V2,pch=".",xlab="Position (Bohr)",ylab="Probability Flux j (AtomicUnits)",ylim=c(-4,4))
    dev.off() #closes the pdf printing device

}

print("Updated ./plots\nMaking moive...\n")

# then convert *.pdf to a .gif with whichever software one wants (platform-dependent)

#system("convert ./plots/*.pdf SHO.gif")